import time

from common.Base import Base
from selenium.webdriver.common.by import By as by

from page.Login import Login


class ThumpsUp(Login):
    """表现层"""
    time.sleep(2)
    # 点赞


    """操作层"""

    def thumps_up(self):
        x = 500
        y = 500
        js = """
    var element = document.elementFromPoint(arguments[0], arguments[1]);
    var evt = document.createEvent("MouseEvents"); 
    evt.initMouseEvent("click", true, true, window, 0, 0, 0, arguments[0], arguments[1]);
    element.dispatchEvent(evt);
        """
        i = 0
        while True:
            self.driver.execute_script(js, x, y)
            time.sleep(0.1)
            i+=1
            if i % 125 == 0:
                time.sleep(10)
            if i % 500 == 0:
                time.sleep(60)


if __name__ == '__main__':
    tp = ThumpsUp()
    tp.login()
    tp.thumps_up()



